<?php
abstract class AbstractClass{
    public abstract function operation1();
    public abstract function operation2();

    public function TemplateMethod(){
        $this->operation1();
        $this->operation2();
        echo '父类';
    }
}

class ConcreteClassA extends AbstractClass{
    public function operation1()
    {
        echo 'A1';
    }

    public function operation2()
    {
        echo 'A2';
    }
}

class ConcreteClassB extends AbstractClass{
    public function operation1()
    {
        echo 'B1';
    }

    public function operation2()
    {
        echo 'B2';
    }
}

//客户端调用
$a = new ConcreteClassA();
$a->TemplateMethod();

$b = new ConcreteClassB();
$b->TemplateMethod();